import { request } from '@/utils/request'
import type { AddressParams } from '@/types/address'
import type { AddressItem } from '@/types/goods'

/**
 * 添加收货地址
 * @param data 请求参数
 */
export const postMemberAddressAPI = (data: AddressParams) => {
  return request('member/address', 'POST', data)
}
/**
 * 获取收货地址列表
 */
export const getMemberAddressAPI = () => {
  return request<AddressItem[]>('member/address')
}
/**
 * 获取收货地址详情
 * @param id 地址id(路径参数)
 */
export const getMemberAddressByIdAPI = (id: string) => {
  return request<AddressItem>(`member/address/${id}`)
}
/**
 * 修改收货地址
 * @param id 地址id(路径参数)
 * @param data 表单数据(请求体参数)
 */
export const putMemberAddressByIdAPI = (id: string, data: AddressParams) => {
  return request(`member/address/${id}`, 'PUT', data)
}
/**
 * 删除收货地址
 * @param id 地址id(路径参数)
 */
export const deleteMemberAddressByIdAPI = (id: string) => {
  return request(`member/address/${id}`, 'DELETE')
}
